---
feature_name: Web Bluetooth / Read Characteristic Value Changed (Async Await)
chrome_version: 55
check_min_version: true
feature_id: 5264933985976320
icon_url: icon.png
index: index.html
---

{% include_relative _includes/intro.html %}

<p>This sample illustrates the use of the Web Bluetooth API to read battery
level and be notified of changes from a nearby Bluetooth Device advertising
Battery information with Bluetooth Low Energy. You may want
to try this demo with the BLE Peripheral
Simulator App from the <a target="_blank"
href="https://play.google.com/store/apps/details?id=io.github.webbluetoothcg.bletestperipheral">Google
Play Store</a> and check out the <a
href="read-characteristic-value-changed.html">Read Characteristic Value Changed
Sample (Promises)</a> sample.</p>

<p>Here, we use the <code>characteristicvaluechanged</code> event listener to
handle reading battery level characteristic value. This event listener will
optionally handle upcoming notifications as well.</p>

<button id="readBatteryLevel">Read Bluetooth Device's Battery Level</button>
<button id="startNotifications" disabled>Start Notifications</button>
<button id="stopNotifications" disabled>Stop Notifications</button>
<button id="reset">Reset Bluetooth Device</button>

{% include output_helper.html %}

{% include js_snippet.html filename='read-characteristic-value-changed-async-await.js' %}

<script>
  document.querySelector('#readBatteryLevel').addEventListener('click', function() {
    if (isWebBluetoothEnabled()) {
      onReadBatteryLevelButtonClick();
    }
  });

  document.querySelector('#startNotifications').addEventListener('click', function(event) {
    if (isWebBluetoothEnabled()) {
      onStartNotificationsButtonClick();
    }
  });

  document.querySelector('#stopNotifications').addEventListener('click', function(event) {
    if (isWebBluetoothEnabled()) {
      onStopNotificationsButtonClick();
    }
  });

  document.querySelector('#reset').addEventListener('click', function(event) {
    if (isWebBluetoothEnabled()) {
      ChromeSamples.clearLog();
      onResetButtonClick();
    }
  });
</script>

{% include_relative _includes/utils.html %}
